<template>
  <div>
<h1>登录</h1>
<table>
  <tr>
    <td>账号</td>
    <td><input type="text" v-model="state.userName"></td>
  </tr>
  <tr>
    <td>密码</td>
    <td><input type="password" v-model="state.userPwd"></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="button" value="登录" @click="login"></td>
  </tr>
</table>
  </div>
</template>

<script setup lang="ts">
import {reactive,toRefs} from 'vue'
import axios from 'axios'
import {useRoute,useRouter} from 'vue-router'
const router=useRouter()
const route=useRoute()

let data=reactive({
  state:{
    userName:'',
    userPwd:''
  }
})

let {state}=toRefs(data)

const login=()=>{
  axios({
    url:'api/XinXi/GetLogin',
    method:'get',
    params:state.value
  })
  .then(res=>{
    if(res.data.data==-1){
      alert('该用户不存在');
      return;
    }
    else if(res.data.data==-2){
      alert('请使用管理员登录');
      return;
    }
    else{
      alert('登录成功');
      router.push('/liebiao');
    }
  })
}
</script>

<style scoped>

</style>